using UnityEngine;
using System.Collections;

[AddComponentMenu("Third Person Props / Fallout Death")]

public class FalloutDeath : MonoBehaviour
{
	void OnTriggerEnter(Collider other)
	{
		//Player falls out
		if(other.GetComponent<ThirdPersonStatus>())
		{
			ThirdPersonStatus fallDeath = other.GetComponent<ThirdPersonStatus>();
			fallDeath.FalloutDeath();	
		}
		//Kill all rigidbodies in this area
		else if(other.attachedRigidbody)
		{
			Destroy(other.attachedRigidbody.gameObject);	
		}
		else if(other.GetType() == typeof(CharacterController))
		{
			Destroy(other.gameObject);	
		}
	}
	
	void Reset()
	{
		if(collider == null)
		{
			gameObject.AddComponent(typeof(BoxCollider));
		}
		
		collider.isTrigger = true;
	}
}
